namespace Interface;

/// <summary>
/// 基础服务接口
/// </summary>
/// <typeparam name="TEntity">实体类型</typeparam>
/// <typeparam name="TVo">视图对象类型</typeparam>
/// <remarks>
/// 提供通用的CRUD业务逻辑接口，自动处理实体与VO之间的映射
/// </remarks>
public interface IBaseService<TEntity, TVo> 
    where TEntity : class, new()
    where TVo : class, new()
{
    /// <summary>
    /// 获取所有记录（返回VO）
    /// </summary>
    /// <returns>VO列表</returns>
    Task<List<TVo>> GetAllAsync();
    
    /// <summary>
    /// 根据ID获取单条记录（返回VO）
    /// </summary>
    /// <param name="id">主键ID</param>
    /// <returns>VO对象，不存在则返回null</returns>
    Task<TVo> GetByIdAsync(object id);
    
    /// <summary>
    /// 分页查询记录（返回VO）
    /// </summary>
    /// <param name="page">页码，从1开始</param>
    /// <param name="pageSize">每页数量</param>
    /// <returns>VO列表</returns>
    Task<List<TVo>> GetPageAsync(int page, int pageSize);
    
    /// <summary>
    /// 添加单条记录
    /// </summary>
    /// <param name="entity">要添加的实体</param>
    /// <returns>是否添加成功</returns>
    Task<bool> AddAsync(TEntity entity);
    
    /// <summary>
    /// 更新记录
    /// </summary>
    /// <param name="entity">要更新的实体</param>
    /// <returns>是否更新成功</returns>
    Task<bool> UpdateAsync(TEntity entity);
    
    
    /// <summary>
    /// 根据ID删除记录
    /// </summary>
    /// <param name="id">主键ID</param>
    /// <returns>是否删除成功</returns>
    Task<bool> DeleteByIdAsync(object id);
}